#include <stdint.h>
#include <stdlib.h>

#include <iostream>
#include <string>

union Simple {
  int64_t num;
  uint8_t alphabet;
};

struct Complex {
  enum DataType { Int, Char } _type;

  union Value {
    int64_t num;
    uint8_t alphabet;

    Value();
    ~Value();
  } _value;
};

void DisplayComplex(Complex const &complex);

int main(int argc, char const *argv[]) {
  Simple s1;
  Simple s2;
  s1.num = 2048;
  s2.alphabet = 'C';
  std::cout << "sizeof(s1): " << sizeof(s1) << std::endl;
  std::cout << "sizeof(s2): " << sizeof(s2) << std::endl;

  Complex c1;
  Complex c2;
  c1._type = Complex::Int;
  c1._value.num = 2048;
  c2._type = Complex::Char;
  c2._value.alphabet = 'C';

  DisplayComplex(c1);
  DisplayComplex(c2);

  return EXIT_SUCCESS;
}

Complex::Value::Value() {}

Complex::Value::~Value() {}

void DisplayComplex(Complex const &c) {
  switch (c._type) {
    case Complex::Int:
      std::cout << "union contains num: " << c._value.num << std::endl;
      break;
    case Complex::Char:
      std::cout << "union contains char: " << c._value.alphabet << std::endl;
      break;
  };
}